package com.bigshen.demo.annotation.configurecomponents.a6LifeCycle;

import com.bigshen.demo.project.entity.lifecycle.AirPlane;
import com.bigshen.demo.project.entity.lifecycle.Car;
import com.bigshen.demo.project.entity.lifecycle.Ship;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MyTest {

    @Test
    public void test() {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class);
        System.out.println("IOC容器初始化完成");

        Car car = (Car) context.getBean("car");
        car.run();

        Ship ship = (Ship) context.getBean("ship");
        ship.swim();

        AirPlane plane = (AirPlane) context.getBean("airPlane");
        plane.fly();

        context.close();
    }

}
